import 'dart:ui';
import 'package:cbec_app/components/app_conifg.dart';
import 'package:cbec_app/utils/AppData.dart';
import 'package:cbec_app/utils/GlobalData.dart';
import 'package:cbec_app/utils/cache_mgr.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'app.dart';

void main() async {
  ///解决启动APP时白屏
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  WidgetsFlutterBinding.ensureInitialized();

  // 强制设置全局浅色模式
// 强制设置全局浅色模式
  final platformDispatcher = PlatformDispatcher.instance;
  platformDispatcher.onPlatformBrightnessChanged = () {
    if (platformDispatcher.platformBrightness == Brightness.dark) {
      // 强制浅色模式
      WidgetsBinding.instance.handlePlatformBrightnessChanged();
    }
  };

  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
  //缓存管理初始化
  await CacheMgr.getInstance();
  //微信登录及支付初始化
  if (GetPlatform.isAndroid || GetPlatform.isIOS) {
    Fluwx fluwx = Fluwx();
    fluwx.registerApi(appId: AppConfig.wxAppid, doOnAndroid: true, doOnIOS: true, universalLink: AppConfig.wxUniversalLink);
  }

  AppData.sid = GlobalData.sid;
// 1793454647563374593
  //启动app 1793454647563374593 1793454647563374593
  runApp(const App());
  // // 判断当前设备是否为安卓
  // if (Platform.isAndroid) {
  //   // 这一步设置状态栏颜色为透明
  //   SystemUiOverlayStyle systemUiOverlayStyle =
  //       SystemUiOverlayStyle(statusBarColor: Colors.transparent);
  //   SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  // }
}
